import org.omg.PortableInterceptor.INACTIVE;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-04-15
 * Time: 12:03
 */
public class Test_0415 implements Runnable{

    public static int countConsistentStrings(String allowed, String[] words) {
        // 均只包含小写字母
        int[] arr = new int[26];
        for(int i = 0; i < allowed.length(); i++) {
            arr[allowed.charAt(i) - 'a'] = 1; // 达到去重效果, 记录 allowed 中字符出现的次数
        }
        int count = 0;
        // 遍历 words 中每个单词是否出现 allowed中字符
        for(int i = 0; i < words.length; i++) {
            boolean flag = true;
            for(int j = 0; j < words[i].length(); j++) {
                if(arr[words[i].charAt(j)-'a'] != 1) {
                    flag = false;
                    break;
                }
            }
            if(flag) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        String allowed = "aba";
        String[] words = new String[]{"ad","bd","aaab","baa","badab"};
        int x = Test_0415.countConsistentStrings(allowed, words);
        System.out.println(x);
    }

    @Override
    public void run() {
        System.out.println("接口中可以有 main 方法");
    }
}

